package response

type PageResult struct {
	List     interface{} `json:"list"`
	Total    int64       `json:"total"`
	PageNum  int         `json:"pageNum"`
	PageSize int         `json:"pageSize"`
}

type Response struct {
	Code int         `json:"code"`
	Data interface{} `json:"data"`
	Msg  string      `json:"msg"`
}

const (
	ERROR   = 7
	SUCCESS = 0
)

func Result(code int, data interface{}, msg string) *Response {
	// 开始时间
	return &Response{
		code,
		data,
		msg,
	}
}
func Ok() *Response {
	return Result(SUCCESS, map[string]interface{}{}, "操作成功")
}

func OkWithMessage(message string) *Response {
	return Result(SUCCESS, map[string]interface{}{}, message)
}

func OkWithData(data interface{}) *Response {
	return Result(SUCCESS, data, "查询成功")
}

func OkWithDetailed(data interface{}, message string) *Response {
	return Result(SUCCESS, data, message)
}

func Fail() *Response {
	return Result(ERROR, map[string]interface{}{}, "操作失败")
}

func FailWithMessage(message string) *Response {
	return Result(ERROR, map[string]interface{}{}, message)
}

func FailWithDetailed(data interface{}, message string) *Response {
	return Result(ERROR, data, message)
}
